package com.ym.controller.patient.pay;

import com.github.pagehelper.PageInfo;
import com.ym.common.constant.Constants;
import com.ym.common.constant.ValidRule;
import com.ym.common.utils.page.PageDomain;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.param.MindQueryMobileParam;
import com.ym.medical.domain.param.MindUpdateParam;
import com.ym.medical.domain.param.ThankMoneyQueryParam;
import com.ym.medical.domain.param.ThankMoneyUpdateParam;
import com.ym.medical.domain.vo.MindListMobileVO;
import com.ym.medical.domain.vo.ThankMoneyListMobileVO;
import com.ym.medical.enums.PaymentStateEnum;
import com.ym.medical.enums.ThankMoneyThankTypeEnum;
import com.ym.medical.service.IMindSV;
import com.ym.medical.service.IThankMoneySV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 患者端-送心意
 *
 * @author: DaiKuangYin
 * @version: 2019年07月15日 10:15
 */
@Api(tags = "患者端-送心意相关")
@RestController
@RequestMapping(value = "/patient/mind", headers = Constants.Api.VERSION)
public class ThankDoctorController extends BaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ThankDoctorController.class);

    @Autowired
    private IThankMoneySV thankMoneySV;

    @Autowired
    private IMindSV mindSV;


    @Log
    @ApiOperation("新增自定义答谢金额")
    @PostMapping(value = "/thankMoney/customer")
    public APIResponse insertThankMoney(@Validated(value = ValidRule.Add.class) @RequestBody ThankMoneyUpdateParam param) {
        thankMoneySV.insertThankMoney(param);
        return success();
    }


    @ApiOperation("送心意")
    @PostMapping(value = "/sendHeart")
    public APIResponse sendHeart(@RequestBody MindUpdateParam param) {
        mindSV.sendHeart(param);
        return success();
    }

    @Log
    @ApiOperation("答谢记录")
    @GetMapping(value = "/thankMoney/record")
    public APIResponse<PageInfo<MindListMobileVO>> thankMoneyRecord(MindQueryMobileParam param) {
        PageDomain.startPage();
        param.setPayState(PaymentStateEnum.HAVE_TO_PAY.getKey());
        List<MindListMobileVO> mindPageInfo = mindSV.selectListMobile(param);
        return successPage(mindPageInfo);
    }

    @Log
    @ApiOperation("标准答谢金额列表")
    @GetMapping(value = "/thankMoney/list")
    public APIResponse<PageInfo<ThankMoneyListMobileVO>> standThankMoneyList() {
        PageDomain.startPage();
        List<ThankMoneyListMobileVO> listMobileVOS = thankMoneySV.selectListMobile(
                ThankMoneyQueryParam
                        .builder()
                        .thankType(ThankMoneyThankTypeEnum.STANDARD_AMOUNT.getKey())
                        .build()
        );
        return successPage(listMobileVOS);
    }

}
